package com.cyt.sys.model.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.cyt.base.util.BaseUtil;
import com.cyt.base.util.DictCode;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 *@Author: YuShengQiang
 *@Date: 2018-11-16 11:05
 *@Description: 基础部分-用户
 */
@Data
@NoArgsConstructor
@Table(name = "base_user")
public class SysUser implements Serializable {

    /**
     * 主键
     */
    @Id
    private String id;

    /**
     * 用户姓名
     */
    @Excel(name = "用户姓名",orderNum = "1")
    private String name;

    /**
     * 登录名称
     */
    @Excel(name = "登录名称",orderNum = "2")
    @Column(name = "login_name")
    private String loginName;

    /**
     * 登录密码
     */
    private String password;

    /**
     * 头像
     */
    @Column(name = "head_logo")
    private String headLogo;

    /**
     * 最后登录时间
     */
    @Excel(name = "最后登录时间",orderNum = "7")
    @Column(name = "last_login_time")
    private Date lastLoginTime;

    /**
     * 最后登录ip
     */
    @Excel(name = "最后登录ip",orderNum = "8")
    @Column(name = "ip_address")
    private String ipAddress;

    /**
     * 用户类型：1、内部人员，2、使用用户
     */
    @Column(name = "user_type")
    private String userType;

    /**
     * 有效状态：1、正常，2、禁用
     */
    @Excel(name = "有效状态",replace = { "正常_1", "禁用_2" },orderNum = "3")
    @Column(name = "status")
    private String status;

    /**
     * 性别：1、男，2、女
     */
    @Excel(name = "性别", replace = {"男_1", "女_2", "_null"}, orderNum = "3")
    @Column(name = "sex")
    private String sex;

    /**
     * 手机号
     */
    @Excel(name = "手机号",orderNum = "3")
    @Column(name = "phone")
    private String phone;

    /**
     * 通用公众号
     */
    @Column(name = "account_id")
    private String accountId;

    /**
     * 用户类型：1、教职工，2、家长，3、学生
     */
    /*@Excel(name = "用户类型",replace = { "教职工_1", "家长_2", "学生_3" },orderNum = "3")
    @Column(name = "user_type")
    private String userType;*/

    /**
     * token
     */
    @Column(name = "token")
    private String token;

    /**
     * 排序
     */
    @Excel(name = "排序",orderNum = "6")
    @Column(name = "sort")
    private String sort;

    /**
     * 加密使用盐
     */
    @Column(name = "salt")
    private String salt;

    /**
     * 删除标识：1、正常，2、已删除
     */
    @Excel(name = "删除标识",replace = { "正常_1", "已删除_2" },orderNum = "9")
    @Column(name = "remove_tag")
    private String removeTag;

    /**
     * 创建人
     */
    @Column(name = "create_user")
    private String createUser;

    /**
     * 创建时间
     */
    @Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss",orderNum = "10")
    @Column(name = "create_time")
    private Date createTime;//创建时间


    /**
     * 修改时间
     */
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 修改人
     */
    @Column(name = "update_user")
    private String updateUser;


    @Transient
    private SysFile sysFile;

    @Excel(name = "组织",orderNum = "4")
    @Transient
    private String orgName;

    @Excel(name = "角色",orderNum = "5")
    @Transient
    private String roleName;
    /**
     * 角色信息
     */
    @Transient
    private List<SysUserRole> sysUserRoleList;

    /**
     * 创建对象
     *
     * @param sysUser 当前用户信息
     * @return
     * @author shengQiang yu
     * @date 2019-04-03 10:53
     */
    public SysUser(SysUser sysUser) {
        this.id= BaseUtil.uId();
        this.removeTag = DictCode.BASE_REMOVE_TAG_NORMAL;
        this.createTime = new Date();
        this.createUser = sysUser.getId();
        this.updateTime = new Date();
        this.updateUser = sysUser.getId();
    }
}